// @vue/component
import {roomsAdd, roomsList} from "@/api/rooms";
import Pagination from "@/components/Pagination/index.vue";

export default {
  name: 'Rooms',

  components: {Pagination},

  mixins: [],

  props: {},

  data () {
    return {
      roomsQuery:{
        room_num:'',
        floor:'',
        status:'',
        page_size:10,
        page_num:1,
        total:0
      },
      roomListData:[],
      roomsAddShow :false,
      listLoading :false,
      roomInfo:{
        room_name:'',
        room_num:'',
        floor:'',
        wifi_name:'',
        wifi_pass:'',
        desc:'',
      }
    }
  },

  computed: {},

  watch: {},

  created () {
    this.getRoomList()
  },

  methods: {

    getRoomList(){
      this.listLoading = true
      roomsList(this.roomsQuery).then(res=>{
        this.roomListData = res.data.data
        this.roomsQuery.total = res.data.page_info.count
        console.log(res)
        this.listLoading = false
      })
    },

    roomAdd(){
      roomsAdd(this.roomInfo).then(res=>{
        if (res.code === 200) {
          this.$notify({
            title: '成功', message: '房间添加成功', type: 'success', duration: 2000
          })
          this.roomsAddShow = false
          this.getRoomList();
        } else {
          this.$notify({
            title: '失败', message: res.message, type: 'error', duration: 2000
          })
        }
      })
    },

    handleUpdate(row,index){

    },

    handleDelete(row,index){

    },
  }
}
